package com.dw.widget.slideshow.db.helper;

import java.util.List;

import android.content.Context;

import com.dw.widget.slideshow.db.object.ImageData;
import com.dw.widget.slideshow.utils.db.DataBaseHelper;
import com.dw.widget.slideshow.utils.db.DataObject;

public class ImageDBHelper extends DataBaseHelper {

	public ImageDBHelper(Context context, String db, Class<ImageData> c) {
		
		super(context, db, c);
	}

	public ImageData[] getRandomImages(final int count)
	{
		if(count <= 0)
		{
			return null;
		}
		
		String suffix = String.format("ORDER BY RANDOM() LIMIT %1$d", count);
		List<DataObject> objs = query(null, suffix);
		if(objs == null)
		{
			return null;
		}
		
		ImageData[] images = objs.toArray(new ImageData[0]);
		return images;
	}
}
